from PyQt5.QtCore import QThread, pyqtSignal
import time

class ProcessThread(QThread):
    # 定义信号
    process_signal = pyqtSignal()
    finished_signal = pyqtSignal()  # 添加完成信号
    
    def __init__(self, interval=100):  # 改为100ms，即0.1秒一次，相当于每秒10次
        super().__init__()
        self.interval = interval / 1000  # 转换为秒
        self.is_running = True
        
    def run(self):
        while self.is_running:
            self.process_signal.emit()  # 发送处理信号
            time.sleep(self.interval)  # 延时
            
    def stop(self):
        self.is_running = False
        self.finished_signal.emit()  # 发送完成信号 